home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / dsiic2.zip / POPDEMO.C < prev    next >
C/C++ Source or Header  |  1991-07-15  |  3KB  |  130 lines

  1. /* Copyright (c) James L. Pinson 1990,1991  */
  2.  
  3. /**********************  POPDEMO.C  ***************************/
  4.  
  5. /* demonstrates the use of pop-up menus */
  6.  
  7. #include "mydef.h"
  8. #include <stdio.h>
  9.  
  10. /* function prototypes */
  11.  
  12. int fake(void);
  13. int prtdemo(void);
  14. int printer(void);
  15. int lpt1(void);
  16. int lpt2(void);
  17. int text(void);
  18.  
  19. int start(int argc, char *argv[])
  20. {
  21. extern struct screen_structure scr;
  22. extern struct window_structure w[];
  23.  
  24. int i;
  25. char string[MAX_STRING];
  26.  
  27.  /* set up menu structure */
  28.  
  29.  struct pop_struc pop_menu [6]={
  30. /*  *name   (*fun)()  select_id  */
  31.     " Sort   " ,fake,   0,
  32.     " Print  " ,prtdemo,0,
  33.     " Delete " ,fake,   0,
  34.     " Copy   " ,fake,   0,
  35.     " Quit   " ,NULL,   1,  /* returns a 1 when selected */
  36.     "\0"      /* mark the end of the options list */
  37.  };
  38.  
  39.  
  40. cls();
  41.  
  42. /* fill the screen with dots '.'*/
  43. /* make up a string of '.' wide enough to fill each row */
  44.  
  45.   for(i=0;i<scr.columns;i++) string[i]='.';  /* build the string */
  46.   string[i]= '\0';                           /* terminate it */
  47.  
  48. /* now fill each row of the screen with the string of '.' */
  49.  
  50.   for (i=1;i<=scr.rows;i++) print(1,i,string);
  51.  
  52. /* create the pop-up menu */
  53. return (pop_up (pop_menu,33,10,scr.normal,scr.inverse));
  54.         /* pop-up appears at column,row 33,10 */
  55.  
  56. }  /* end of start(); */
  57.  
  58.  
  59. int prtdemo()
  60. {
  61. extern struct screen_structure scr;
  62. extern struct window_structure w[];
  63.  
  64. int return_code;
  65.  
  66.  /* set up menu structure */
  67.  
  68.  struct pop_struc pop_menu [3]={
  69.  
  70. /*  *name        (*fun)()  select_id  */
  71.  " Printer   "  ,printer,  0,
  72.  " Text-file  " ,text,     0,
  73.  "\0"      /* mark the end of the options list */
  74.  };
  75.  
  76. /* call routine to handle menu */
  77. return_code= (pop_up (pop_menu,41,13,scr.normal,scr.inverse));   
  78.              /* pop-up appears at column-row */
  79.              /* 41,13 */
  80.  
  81. /* we could examine return_code here if necessary */
  82.  
  83. return(0); /* return a zero so the parent menu does not close */
  84. }
  85.  
  86.  
  87. int printer()
  88. {
  89. extern struct screen_structure scr;
  90. extern struct window_structure w[];
  91.  
  92.  /* set up menu structure */
  93.  
  94.  struct pop_struc pop_menu [3]={
  95.  
  96. /*  *name        (*fun)()  select_id  */
  97.   " Lpt1:   ",   lpt1,     0,
  98.   " lPt2:  " ,   lpt2,     0,
  99.   "\0"      /* mark the end of the options list */
  100.  };
  101.  
  102. /* call routine to handle menu */
  103. return (pop_up (pop_menu,53,15,scr.normal,scr.inverse));   
  104.         /* pop-up appears at column-row 53,15 */
  105. }
  106.  
  107.  
  108. int lpt1(void)
  109. {
  110. return(1);  /* return a non-zero number to close menu */
  111. }
  112.  
  113.  
  114. int lpt2(void)
  115. {
  116. return(1);  /* return a non-zero number to close menu */
  117. }
  118.  
  119.  
  120. int text(void)
  121. {
  122. return(1);  /* return a non-zero number to close menu */
  123. }
  124.  
  125.  
  126. int fake(void)
  127. {
  128. return(0);  /* return a zero so the menu does not close */
  129. }
  130.